<template>
    <div id="Replenishment">
        <v-detail :detailData="inputData"
                  :inputConfig="inputConfig"
                  :rules="rules"
                  ref="input"></v-detail>
    </div>
</template>

<script>
import detail from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
    name: "Replenishment",
    mixins: [baseMixin],
    props: {
        inputData: {
            type: Object
        }
    },
    data() {

        //自定义验证规则
        const numValidate = (rule, value, callback) => {
            let reg = /^\+?[0-9]\d*$/;//大于零的正整数
            if (!reg.test(value)) {
                this.$message.error(this.$t('app.inputGreaterZeroNumberPlease'));
                this.inputData[rule.field] = 0
                callback(new Error())
            } else {
                callback()
            }
        }
        return {
            inputConfig: [
                [
                    {
                        type: "select",
                        label: this.$t('outbound.replenishment'),
                        props: "replenishmentmethod",
                        options: this.getOptions('querycodeLkup/REPLNMTHD')
                    },
                    {
                        type: "input",
                        label: this.$t('config.maxVolume'),
                        props: "maxcube",
                    },
                ],
                [
                    {
                        type: "input",
                        label: this.$t('config.maxWeight'),
                        props: "maxweight",
                    },
                    {
                        type: "input",
                        label: this.$t('outbound.labormaxcasecnt'),
                        props: "maxcasecnt",
                    }
                ]
            ],
            rules: {
                replenishmentmethod: [
                    {required: true, message: '请选择补货方法', trigger: 'blur'},
                ],
                maxcube: [
                    {required: true, message: this.$inputPlease("config.maxVolume"), trigger: 'blur', validator: numValidate},
                ],
                maxweight: [
                    {required: true, message: this.$inputPlease("config.maxWeight"), trigger: 'blur', validator: numValidate},
                ],
                maxcasecnt: [
                    {required: true, message: this.$inputPlease("config.maxCarton"), trigger: 'blur', validator: numValidate},
                ]
            },
        }
    },
    methods: {},
    mounted() {

    },
    components: {
        "v-detail": detail
    }
}
</script>

<style scoped>
</style>
